#!/usr/bin/env python
# encoding: utf-8

print "cwimport"

# built-in stuff
import unittest
# stuff to test
from cwimport import *

env= {
	"prefs": {
		"cwImport_defaultDirectory": ".",
		"cwImport_defaultEncoding": "utf8",
	},
	"static": {
		"cwImport_label": "%s",
	}
}


class CwImportTest(unittest.TestCase):
	
	def testUtf8Text(self):
		env["context"]= {"selection":"test-utf8.txt"}
		self.assert_(main(env)[0][1]["text"].startswith(u"Jean de La Fontaine (8 juillet 1621 à Château-Thierry"))
	
	def testIOError(self):
		env["context"]= {"selection":"not a file"}
		self.assertRaises(IOError,main,env)

if __name__ == '__main__':
	unittest.main()
